package cf.jone.test

import android.databinding.DataBindingUtil
import android.databinding.ObservableField
import android.databinding.ViewDataBinding
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.jone.base.binding.command.BaseCommand
import com.jone.base.binding.command.ICommand
import com.jone.base.http.HttpHelper
import com.jone.base.http.IHttpResponseCallback
import com.jone.base.http.RequestParams
import com.jone.base.http.ResponseModel
import com.jone.base.json.JsonHelper
import com.jone.base.utils.LogUtils

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val binding = DataBindingUtil.setContentView<ViewDataBinding>(MainActivity@ this, R.layout.activity_main)
        binding.setVariable(BR.viewModel, this@MainActivity)

        LogUtils.init(this)
    }

    val testText = ObservableField<String>("Click")

//    val TestCommand: ICommand by lazy {
//        baseCommand<Any?>{ _ ->
//            HttpHelper.post("http://api.k780.com/").params("haha", "dddd")
//                    .execute(object : IHttpResponseCallback {
//                        override fun onPreExecute(params: RequestParams) {
//                        }
//
//                        override fun onSuccess(responseModel: ResponseModel) {
//                            JsonHelper.convertJsonToObject(responseModel.jsonStr!!, String::class.java)
//                        }
//
//                        override fun onError(e: Exception) {
//                        }
//
//                        override fun onFinish() {
//                        }
//
//                        override fun onProgress(progress: Float) {
//                        }
//
//                        override fun getResponseModelType(): Class<*> {
//                            return String::class.java
//                        }
//                    })
//        }
//    }

//    val TestCommand: ICommand by lazy {
//        object : BaseCommand<Any?>() {
//            override fun execute(commandParameter: Any?) {
//                HttpHelper.post("http://api.k780.com/").params("haha","dddd")
//                        .execute(object : IHttpResponseCallback {
//                            override fun onPreExecute(params: RequestParams) {
//                            }
//
//                            override fun onSuccess(responseModel: ResponseModel) {
//                                JsonHelper.convertJsonToObject(responseModel.jsonStr!!,String::class.java)
//                            }
//
//                            override fun onError(e: Exception) {
//                            }
//
//                            override fun onFinish() {
//                            }
//
//                            override fun onProgress(progress: Float) {
//                            }
//
//                            override fun getResponseModelType(): Class<*> {
//                                return String::class.java
//                            }
//                        })
//            }
//
//        }
//    }




}
